#ifndef USRAI_H
#define USRAI_H

#include "AI.h"

extern tagGame tagUsrGame;
extern ins UsrIns;
/*##########DO NOT MODIFY THE CODE ABOVE##########*/

class UsrAI:public AI
{
public:
    UsrAI(){this->id=0;}
    ~UsrAI(){}

private:
    void processData() override;
    tagInfo getInfo(){return tagUsrGame.getInfo();}
    int AddToIns(instruction ins) override
    {
        UsrIns.lock.lock();
        ins.id=UsrIns.g_id;
        UsrIns.g_id++;
        UsrIns.instructions.push(ins);
        UsrIns.lock.unlock();
        return ins.id;
    }
    void clearInsRet() override
    {
        tagUsrGame.clearInsRet();
    }
    /*##########DO NOT MODIFY THE CODE IN THE CLASS##########*/
    bool tryBuildBuilding(int buildingType, int requiredWood, int maxCount, int reqiredBuilding,int is_settler=0);
    //my function
    void arrangeFarmer(tagInfo info);
    void arrangeSailingBoat(tagInfo info);
    void arrangeHome(tagInfo info);
    void arrangeCenter(tagInfo info);
    void arrangeDock(tagInfo info);
    void arrangeShip(tagInfo info);
    void arrangeWoodBoat(tagInfo info);
    void arrangeMarket(tagInfo info);
    void arrangeGranary(tagInfo info);
    void arrangeFarm(tagInfo info);
    void arrangeStock(tagInfo info);
    void arrangeE_farmer(tagInfo info);
    void arrangeArmycamp(tagInfo info);
    void arrangeRange(tagInfo info);
    void arrangeStable(tagInfo info);
    void arrangeArrowtower(tagInfo info);
    void arrangeArmy_on_land(tagInfo info);
    //stage1
    void createMAP(char map[][128],tagInfo info);
    void show_MAP(char map[][128]);
    int findResource(tagFarmer farmer, int Type,tagInfo info);
    void farmer_to_tree(int k,tagInfo info);
    void farmer_to_tree2(int k,tagInfo info);
    bool find_block(int& x,int& y,tagInfo info);
    bool idleblock(int x,int y,tagInfo info);
    void farmer_to_home(tagInfo info);
    bool find_sea(tagInfo info);
    void farmer_to_dock(tagInfo info);
    bool find_block3(int& x,int& y,tagInfo info);
    bool find_block3_2(int& x,int& y,tagInfo info);
    bool find_block3_3(int& x,int& y,tagInfo info);
    bool find_block3_4(int& x,int& y,tagInfo info);
    void farmer_to_granary(tagInfo info);
    void farmer_to_stone(int k,tagInfo info);
    int findFish(tagFarmer farmer, tagInfo info);
    void farmer_to_fish(tagInfo info,int k);
    void farmer_hunt_GZ(tagInfo info,int k);
    void farmer_hunt_EL(int k,tagInfo info);
    void farmer_hunt_EL2(int k,tagInfo info);
    void sailing_to_fish(int k,tagInfo info);
    //stage2
    bool find_Market_block(int& x,int& y,tagInfo info);
    void farmer_to_market(tagInfo info);
    bool farm_block(int &x,int &y,tagInfo info);
    void farmer_to_farm(tagInfo info);
    void Dock_to_ship(int n,tagInfo info);
    int find_enemy(int &x,int &y);
    void find_begin_sea(tagInfo info);
    void ship_find_enemy1(tagInfo info);
    void ship_find_enemy2(tagInfo info);
    void sailing_explore(tagInfo info);
    bool no_forest(int x,int y,tagInfo info);
    void decide_land1(tagInfo info);
    bool is_enemy_ship(tagInfo info);
    void push_Boat_farmer(tagInfo info);
    void farmer_to_WoodBoat(tagInfo info);
    bool farmer_on_boat(tagInfo info);
    bool farmer_to_land(int k,tagInfo info);
    //stage3
    void sort_E_idlefarmer(tagInfo info);
    void farmer_to_stock(tagInfo info);
    void farmer_to_armycamp(tagInfo info);
    void farmer_to_range(tagInfo info);
    void farmer_to_stable(tagInfo info);
    void farmer_explore(tagInfo info);
    bool have_gold(tagInfo info);
    void farmer_to_gold(int k,tagInfo info);
    void scout_attack(int obSN,tagInfo info);
    void scout_explore(tagInfo info);
    void scout_explore2(tagInfo info);
    void swordsman_part(int obSN,tagInfo info);
    void slinger_part(int obSN,tagInfo info);
    void bowman_attack(int obSN,tagInfo info);
    void clubman_part(int obSN,tagInfo info);
    void decide_enemy_block(tagInfo info);
    void ship_attack(int obSN,tagInfo info);
    void farmer_to_arrowtower(tagInfo info);
    bool many_gold(tagInfo info,char map[][128]);
};

/*##########YOUR CODE BEGINS HERE##########*/
    
/*##########YOUR CODE ENDS HERE##########*/
#endif // USRAI_H
